There are 3 Error Modes in DarkNet which deal with errors in different ways. Multiple Error Modes can be enabled at the same time. Error Modes are enabled and disabled by mnToggleErrorMode and by default only EM_MESSAGE_BOX is enabled.
When an error occurs an error message box is displayed.
When an error occurs mnGetErrorFlag returns true and you can use mnGetErrorFull, mnGetErrorOperation, mnGetErrorCommand, mnGetErrorLine, mnGetErrorFile and mnGetErrorCode to retrieve information about the error.
When an error occurs an exception is
generated. In C++ this is of type clError and in .NET this is of type
mnError. You should not use this error mode in DBP as DBP does not support
exception handling.
The DarkNet error type contains information
about the error. In C++ the members sFullMessage, sOperation, sCommand,
iErrorCode, iLine and sFile exist and in .NET the member functions GetFullMessage,
GetOperation, GetCommand, GetErrorCode, GetLine and GetFile exist.
Other member functions such as SetCore,
SetCommand and SetFull exist which are used internally and can be used
by your application when dealing with errors. Unless you want to use
the same system that DarkNet does to deal with errors, you do not need
to read further.
At the initial error point, SetCore should
be used to set the operation, error code, line number and code file
of the error. An exception should then be thrown of DarkNet error type
(clError or mnError).
This should then be caught by a function
and GenRethrow, GenMessageBox or GenEvent should be used. GenRethrow
throws an exception and GenMessageBox displays a message box (both regardless
of error mode). GenEvent decides what to do depending on the error mode.
If you want to throw the final exception
at the initial error point, you can use the overloaded versions of GenRethrow,
GenMessageBox or GenEvent to set the command at the same time as the
core.
Optionally you can use Generate after SetCore and SetCommand to prepare the error. You can then use DoMessageBox, DoSave, DoRethrow or DoEvent to report the error.